package com.durian.base.rxhttp.ssl

import android.os.Build
import java.lang.Exception

/**
 * 说明：Platform
 * <p/>
 * 作者：Fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020/04/24 11:46
 * <p/>
 * 版本：version 1.0
 */

open class Platform {

    companion object {
        fun get(): Platform {
            try {
                Class.forName("android.os.Build")
                if (Build.VERSION.SDK_INT != 0) {
                    return Android()
                }
            } catch (e: Exception) {
                e.printStackTrace()
            }
            return Platform()
        }
    }

    open fun isAndroid(): Boolean {
        return false
    }

    open fun sdkLessThan(api: Int): Boolean {
        return false
    }

}

class Android : Platform() {
    override fun isAndroid(): Boolean {
        return true
    }

    override fun sdkLessThan(api: Int): Boolean {
        return Build.VERSION.SDK_INT < api
    }
}